package com.wuzuqing.android.eightdiagrams

import android.widget.TextView
import androidx.core.content.ContextCompat
import com.wuzuqing.android.eightdiagrams.base.BaseAdapter
import com.wuzuqing.android.eightdiagrams.base.BaseViewHolder
import com.wuzuqing.android.eightdiagrams.model.BaZiInfo

/**
 * @CopyRight: 广州仰望星空云科技有限公司
 * @Author : wuzuqing
 * @Email:wuzuqing@xinyu668.com
 * @CreateTime: 12.12.23 3:44 PM
 * @Description: 请写描述
 */


class ResultAdapter : BaseAdapter<BaZiInfo.ShowItem>(R.layout.item_result) {
    var colorT2 = ContextCompat.getColor(App.getContext(), R.color.colorT2)
    var colorT3 = ContextCompat.getColor(App.getContext(), R.color.colorT3)
    var colorT5 = ContextCompat.getColor(App.getContext(), R.color.colorT5)
    var colorT6 = ContextCompat.getColor(App.getContext(), R.color.colorT6)
    var colorT7 = ContextCompat.getColor(App.getContext(), R.color.colorT7)
    var colorT8 = ContextCompat.getColor(App.getContext(), R.color.colorT8)
    var colorT9 = ContextCompat.getColor(App.getContext(), R.color.colorT9)
    var colorT10 = ContextCompat.getColor(App.getContext(), R.color.colorT10)
    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        getItem(position)?.also {
            val textView: TextView = holder.getView(R.id.text1)
            textView.text = it.text
            when (it.type) {
                1 -> textView.setTextColor(colorT3)
                3 -> textView.setTextColor(colorT10)
                2 -> {
                    if (it.text.length > 2) {
                        when (it.text[1]) {
                            '金' -> textView.setTextColor(colorT5)
                            '木' -> textView.setTextColor(colorT6)
                            '水' -> textView.setTextColor(colorT7)
                            '火' -> textView.setTextColor(colorT8)
                            '土' -> textView.setTextColor(colorT9)
                        }
                    } else {
                        textView.setTextColor(colorT10)
                    }
                }
            }
        }
    }
}